<template>
  <div>
    您好，{{ username }}<br/>
    个性签名:{{ sign }}
    <br>
    <br>
    <br>
    发布文章<br/>
    <van-field v-model='form.title' label='标题'/>
    <van-field rows=3 cols=5 type='textarea' v-model='form.content' label='内容'/>
    <van-button @click='add'>添加</van-button>

    <br/>展示文章<br/>
    <br/>
    <van-button @click='my'>我的文章</van-button>
    <br/>
    <table>
      <tr>
        <td>id</td>
        <td>标题</td>
        <td>内容</td>
      </tr>
      <tr v-for='i in alist'>
        <td>{{ i.id }}</td>
        <td>{{ i.title }}</td>
        <td>{{ i.content }}</td>
      </tr>
    </table>
  </div>
</template>
<script>
export default {
  data() {
    return {
      username: localStorage.getItem('username'),
      sign: localStorage.getItem('sign'),
      form: {'userid': localStorage.getItem('userid')},
      alist: [],
      uid: 0
    }
  },
  methods: {
    add() {
      this.axios.post('auser/articleM', this.form).then(res => {
        if (res.data.code == 200) {
          this.getlist()
        }
      })
    },
    getlist() {
      this.axios.get('auser/articleM?uid=' + this.uid).then(res => {
        this.alist = res.data.list
      })
    },
    //我的文章
    my() {
      this.uid = this.form.userid
      this.getlist()
    }
  },
  mounted() {
    this.getlist()
  },
}
</script>
<style lang="">

</style>